
package gui.panels.components;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;

/**
 *
 * @author JtR
 */
public class MmiButton extends JButton {
    private Image image;
        
    public MmiButton(String filename, int width) {
        super();
        try {
            image = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream(filename));
            int height = (int)(image.getHeight(null) * ((float)width / (float)image.getWidth(null)));
            setPreferredSize(new Dimension(width, height));
            image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
            setIcon(new ImageIcon(image));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        
        setOpaque(false);
        setContentAreaFilled(false);
        setBorderPainted(false);
    }
}
